namespace QMVnSoft.Invoices
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.Controls.ChildGridControls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormCTSXF0Editor : FormControl
    {
        private BtnControl btnClose;
        private BtnControl btnMakeCommand;
        private BtnControl btnMakeRequire;
        private DataGridViewTextBoxColumn Column1;
        private DataGridViewTextBoxColumn Column2;
        private DataGridViewTextBoxColumn Column3;
        private NumericColumn Column4;
        private NumericColumn Column5;
        private NumericColumn Column6;
        private IContainer components;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
        private SplitContainer grdContainer;
        private GridControl grdDetail;
        private GridControl grdMaster;
        private bool ib_CheckAccepted;
        private object is_MasterKey;
        private object is_ParentKey;
        private NumericColumn numericColumn1;
        private NumericColumn numericColumn10;
        private NumericColumn numericColumn11;
        private NumericColumn numericColumn12;
        private NumericColumn numericColumn13;
        private NumericColumn numericColumn14;
        private NumericColumn numericColumn15;
        private NumericColumn numericColumn17;
        private NumericColumn numericColumn2;
        private NumericColumn numericColumn3;
        private NumericColumn numericColumn4;
        private NumericColumn numericColumn5;
        private NumericColumn numericColumn6;
        private NumericColumn numericColumn7;
        private DataTable oLocalDetailTable;
        private DataTable oLocalMasterTable;
        private DataTable oLocalSelectedTable;
        private CTSXDataAccess oMethod = new CTSXDataAccess();
        private DataRow oParentRow;

        public FormCTSXF0Editor(object ps_ParentKey, DataRow po_MasterRow)
        {
            this.InitializeComponent();
            this.ParentKey = ps_ParentKey;
            this.LocalMasterRow = po_MasterRow;
            this.grdMaster.AutoGenerateColumns = false;
            this.grdDetail.AutoGenerateColumns = false;
            this.CreateSelectedTable();
            this.OnFillData();
            base.ResizeForm();
        }

        private void Close_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void CreateDetailTable()
        {
            DataTable table = new DataTable();
            DataColumn column = new DataColumn("Stt0", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ma_Bp", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ma_Hd", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ma_Vt", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ten_Vt", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Dvt", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("So_Luong0", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("So_Luong1", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("Ton_Kho1", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("Ton_Kho2", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("Ton_Kho3", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("Ton_Kho4", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("Ton_Kho5", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("Ton_Kho0", typeof(decimal));
            table.Columns.Add(column);
            column = new DataColumn("So_Luong2", typeof(decimal));
            table.Columns.Add(column);
            this.LocalDetailTable = table;
        }

        private void CreateSelectedTable()
        {
            DataTable table = new DataTable();
            DataColumn column = new DataColumn("Stt0", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ma_Bp", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ma_Hd", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ma_Vt", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Ten_Vt", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("Dvt", typeof(string));
            table.Columns.Add(column);
            column = new DataColumn("So_Luong", typeof(decimal));
            table.Columns.Add(column);
            table.PrimaryKey = new DataColumn[] { table.Columns["Stt0"], table.Columns["Ma_Vt"] };
            this.LocalSelectedTable = table;
        }

        private void DetailGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            decimal num = 0M;
            DataRow row = ((DataRowView) this.MasterGrid.CurrentRow.DataBoundItem).Row;
            foreach (DataRow row2 in this.LocalDetailTable.Rows)
            {
                if ((row2.RowState != DataRowState.Deleted) && !row2["So_Luong"].Equals(DBNull.Value))
                {
                    num += (decimal) row2["So_Luong"];
                }
            }
            row["So_Luong"] = num;
            row.EndEdit();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            DataGridViewCellStyle style2 = new DataGridViewCellStyle();
            DataGridViewCellStyle style3 = new DataGridViewCellStyle();
            DataGridViewCellStyle style4 = new DataGridViewCellStyle();
            DataGridViewCellStyle style5 = new DataGridViewCellStyle();
            DataGridViewCellStyle style6 = new DataGridViewCellStyle();
            DataGridViewCellStyle style7 = new DataGridViewCellStyle();
            DataGridViewCellStyle style8 = new DataGridViewCellStyle();
            DataGridViewCellStyle style9 = new DataGridViewCellStyle();
            DataGridViewCellStyle style10 = new DataGridViewCellStyle();
            DataGridViewCellStyle style11 = new DataGridViewCellStyle();
            DataGridViewCellStyle style12 = new DataGridViewCellStyle();
            DataGridViewCellStyle style13 = new DataGridViewCellStyle();
            DataGridViewCellStyle style14 = new DataGridViewCellStyle();
            DataGridViewCellStyle style15 = new DataGridViewCellStyle();
            DataGridViewCellStyle style16 = new DataGridViewCellStyle();
            DataGridViewCellStyle style17 = new DataGridViewCellStyle();
            this.grdContainer = new SplitContainer();
            this.grdMaster = new GridControl();
            this.grdDetail = new GridControl();
            this.btnMakeRequire = new BtnControl();
            this.btnMakeCommand = new BtnControl();
            this.btnClose = new BtnControl();
            this.Column1 = new DataGridViewTextBoxColumn();
            this.Column2 = new DataGridViewTextBoxColumn();
            this.Column3 = new DataGridViewTextBoxColumn();
            this.Column4 = new NumericColumn();
            this.Column5 = new NumericColumn();
            this.Column6 = new NumericColumn();
            this.numericColumn1 = new NumericColumn();
            this.numericColumn2 = new NumericColumn();
            this.numericColumn3 = new NumericColumn();
            this.numericColumn4 = new NumericColumn();
            this.numericColumn5 = new NumericColumn();
            this.numericColumn6 = new NumericColumn();
            this.numericColumn7 = new NumericColumn();
            this.dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
            this.dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
            this.numericColumn10 = new NumericColumn();
            this.numericColumn11 = new NumericColumn();
            this.numericColumn12 = new NumericColumn();
            this.numericColumn13 = new NumericColumn();
            this.numericColumn14 = new NumericColumn();
            this.numericColumn15 = new NumericColumn();
            this.numericColumn17 = new NumericColumn();
            this.grdContainer.Panel1.SuspendLayout();
            this.grdContainer.Panel2.SuspendLayout();
            this.grdContainer.SuspendLayout();
            ((ISupportInitialize) this.grdMaster).BeginInit();
            ((ISupportInitialize) this.grdDetail).BeginInit();
            base.SuspendLayout();
            this.grdContainer.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.grdContainer.Location = new Point(0, 0x2d);
            this.grdContainer.Name = "grdContainer";
            this.grdContainer.Orientation = Orientation.Horizontal;
            this.grdContainer.Panel1.Controls.Add(this.grdMaster);
            this.grdContainer.Panel2.Controls.Add(this.grdDetail);
            this.grdContainer.Size = new Size(0x31a, 0x1e7);
            this.grdContainer.SplitterDistance = 0xe3;
            this.grdContainer.SplitterWidth = 1;
            this.grdContainer.TabIndex = 0;
            this.grdMaster.AllowUserToAddRows = false;
            this.grdMaster.AllowUserToDeleteRows = false;
            this.grdMaster.CheckAutoSize = true;
            this.grdMaster.CheckColor = false;
            this.grdMaster.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdMaster.Columns.AddRange(new DataGridViewColumn[] { this.Column1, this.Column2, this.Column3, this.Column4, this.Column5, this.Column6, this.numericColumn1, this.numericColumn2, this.numericColumn3, this.numericColumn4, this.numericColumn5, this.numericColumn6, this.numericColumn7 });
            this.grdMaster.Dock = DockStyle.Fill;
            this.grdMaster.Font = new Font("Arial", 8.25f);
            this.grdMaster.Location = new Point(0, 0);
            this.grdMaster.Name = "grdMaster";
            this.grdMaster.Size = new Size(0x31a, 0xe3);
            this.grdMaster.TabIndex = 4;
            this.grdMaster.CellEnter += new DataGridViewCellEventHandler(this.MasterGrid_CellEnter);
            this.grdDetail.AllowUserToAddRows = false;
            this.grdDetail.AllowUserToDeleteRows = false;
            this.grdDetail.CheckAutoSize = true;
            this.grdDetail.CheckColor = false;
            this.grdDetail.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdDetail.Columns.AddRange(new DataGridViewColumn[] { this.dataGridViewTextBoxColumn1, this.dataGridViewTextBoxColumn2, this.dataGridViewTextBoxColumn3, this.numericColumn10, this.numericColumn11, this.numericColumn12, this.numericColumn13, this.numericColumn14, this.numericColumn15, this.numericColumn17 });
            this.grdDetail.Dock = DockStyle.Fill;
            this.grdDetail.Font = new Font("Arial", 8.25f);
            this.grdDetail.Location = new Point(0, 0);
            this.grdDetail.Name = "grdDetail";
            this.grdDetail.Size = new Size(0x31a, 0x103);
            this.grdDetail.TabIndex = 5;
            this.grdDetail.CellEndEdit += new DataGridViewCellEventHandler(this.DetailGrid_CellEndEdit);
            this.btnMakeRequire.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.btnMakeRequire.Font = new Font("Arial", 8.25f);
            this.btnMakeRequire.Location = new Point(0x170, 12);
            this.btnMakeRequire.Name = "btnMakeRequire";
            this.btnMakeRequire.Size = new Size(0x86, 0x17);
            this.btnMakeRequire.TabIndex = 1;
            this.btnMakeRequire.Text = "Lập yêu cầu mua hàng";
            this.btnMakeRequire.UseVisualStyleBackColor = true;
            this.btnMakeRequire.Visible = false;
            this.btnMakeRequire.Click += new EventHandler(this.MakeRequire_Click);
            this.btnMakeCommand.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.btnMakeCommand.Font = new Font("Arial", 8.25f);
            this.btnMakeCommand.Location = new Point(0x1fc, 12);
            this.btnMakeCommand.Name = "btnMakeCommand";
            this.btnMakeCommand.Size = new Size(0x86, 0x17);
            this.btnMakeCommand.TabIndex = 1;
            this.btnMakeCommand.Text = "Lập lệnh sản xuất";
            this.btnMakeCommand.UseVisualStyleBackColor = true;
            this.btnMakeCommand.Click += new EventHandler(this.MakeCommand_Click);
            this.btnClose.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.btnClose.Font = new Font("Arial", 8.25f);
            this.btnClose.Location = new Point(0x288, 12);
            this.btnClose.Name = "btnClose";
            this.btnClose.Size = new Size(0x86, 0x17);
            this.btnClose.TabIndex = 1;
            this.btnClose.Text = "Quay ra";
            this.btnClose.UseVisualStyleBackColor = true;
            this.btnClose.Click += new EventHandler(this.Close_Click);
            this.Column1.DataPropertyName = "Ma_Vt";
            this.Column1.HeaderText = "Vật tư";
            this.Column1.Name = "Column1";
            this.Column1.ReadOnly = true;
            this.Column1.Width = 60;
            this.Column2.DataPropertyName = "Ten_Vt";
            this.Column2.HeaderText = "Tên vật tư";
            this.Column2.Name = "Column2";
            this.Column2.ReadOnly = true;
            this.Column2.Width = 150;
            this.Column3.DataPropertyName = "Dvt";
            this.Column3.HeaderText = "Đvt";
            this.Column3.Name = "Column3";
            this.Column3.ReadOnly = true;
            this.Column3.Width = 0x1d;
            this.Column4.DataPropertyName = "So_Luong0";
            style.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.Column4.DefaultCellStyle = style;
            this.Column4.HeaderText = "Lệnh";
            this.Column4.Name = "Column4";
            this.Column4.ReadOnly = true;
            this.Column4.SortMode = DataGridViewColumnSortMode.Automatic;
            this.Column4.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.Column4.Width = 0x40;
            this.Column5.DataPropertyName = "So_Luong1";
            style2.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.Column5.DefaultCellStyle = style2;
            this.Column5.HeaderText = "Thực hiện";
            this.Column5.Name = "Column5";
            this.Column5.ReadOnly = true;
            this.Column5.SortMode = DataGridViewColumnSortMode.Automatic;
            this.Column5.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.Column5.Width = 0x40;
            this.Column6.DataPropertyName = "Ton_Kho1";
            style3.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.Column6.DefaultCellStyle = style3;
            this.Column6.HeaderText = "Tồn kho";
            this.Column6.Name = "Column6";
            this.Column6.ReadOnly = true;
            this.Column6.SortMode = DataGridViewColumnSortMode.Automatic;
            this.Column6.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.Column6.Width = 0x40;
            this.numericColumn1.DataPropertyName = "Ton_Kho2";
            style4.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn1.DefaultCellStyle = style4;
            this.numericColumn1.HeaderText = "Đơn hàng";
            this.numericColumn1.Name = "numericColumn1";
            this.numericColumn1.ReadOnly = true;
            this.numericColumn1.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn1.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn1.Visible = false;
            this.numericColumn1.Width = 0x40;
            this.numericColumn2.DataPropertyName = "Ton_Kho3";
            style5.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn2.DefaultCellStyle = style5;
            this.numericColumn2.HeaderText = "Thành phẩm";
            this.numericColumn2.Name = "numericColumn2";
            this.numericColumn2.ReadOnly = true;
            this.numericColumn2.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn2.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn2.Width = 0x40;
            this.numericColumn3.DataPropertyName = "Ton_Kho4";
            style6.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn3.DefaultCellStyle = style6;
            this.numericColumn3.HeaderText = "Yêu cầu nhập";
            this.numericColumn3.Name = "numericColumn3";
            this.numericColumn3.ReadOnly = true;
            this.numericColumn3.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn3.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn3.Visible = false;
            this.numericColumn3.Width = 0x40;
            this.numericColumn4.DataPropertyName = "Ton_Kho5";
            style7.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn4.DefaultCellStyle = style7;
            this.numericColumn4.HeaderText = "Yêu cầu xuất";
            this.numericColumn4.Name = "numericColumn4";
            this.numericColumn4.ReadOnly = true;
            this.numericColumn4.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn4.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn4.Width = 0x40;
            this.numericColumn5.DataPropertyName = "Ton_Kho0";
            style8.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn5.DefaultCellStyle = style8;
            this.numericColumn5.HeaderText = "Tổng";
            this.numericColumn5.Name = "numericColumn5";
            this.numericColumn5.ReadOnly = true;
            this.numericColumn5.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn5.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn5.Width = 0x40;
            this.numericColumn6.DataPropertyName = "So_Luong2";
            style9.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn6.DefaultCellStyle = style9;
            this.numericColumn6.HeaderText = "Còn lại";
            this.numericColumn6.Name = "numericColumn6";
            this.numericColumn6.ReadOnly = true;
            this.numericColumn6.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn6.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn6.Width = 0x40;
            this.numericColumn7.DataPropertyName = "So_Luong";
            style10.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn7.DefaultCellStyle = style10;
            this.numericColumn7.HeaderText = "Lập";
            this.numericColumn7.Name = "numericColumn7";
            this.numericColumn7.ReadOnly = true;
            this.numericColumn7.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn7.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn7.Width = 0x40;
            this.dataGridViewTextBoxColumn1.DataPropertyName = "Ma_Vt";
            this.dataGridViewTextBoxColumn1.HeaderText = "Vật tư";
            this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
            this.dataGridViewTextBoxColumn1.ReadOnly = true;
            this.dataGridViewTextBoxColumn1.Width = 0x4f;
            this.dataGridViewTextBoxColumn2.DataPropertyName = "Ten_Vt";
            this.dataGridViewTextBoxColumn2.HeaderText = "Tên vật tư";
            this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
            this.dataGridViewTextBoxColumn2.ReadOnly = true;
            this.dataGridViewTextBoxColumn2.Width = 240;
            this.dataGridViewTextBoxColumn3.DataPropertyName = "Dvt";
            this.dataGridViewTextBoxColumn3.HeaderText = "Đvt";
            this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
            this.dataGridViewTextBoxColumn3.ReadOnly = true;
            this.dataGridViewTextBoxColumn3.Width = 0x20;
            this.numericColumn10.DataPropertyName = "Ton_Kho1";
            style11.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn10.DefaultCellStyle = style11;
            this.numericColumn10.HeaderText = "Tồn kho";
            this.numericColumn10.Name = "numericColumn10";
            this.numericColumn10.ReadOnly = true;
            this.numericColumn10.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn10.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn10.Width = 80;
            this.numericColumn11.DataPropertyName = "Ton_Kho2";
            style12.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn11.DefaultCellStyle = style12;
            this.numericColumn11.HeaderText = "Đơn hàng";
            this.numericColumn11.Name = "numericColumn11";
            this.numericColumn11.ReadOnly = true;
            this.numericColumn11.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn11.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn11.Visible = false;
            this.numericColumn11.Width = 80;
            this.numericColumn12.DataPropertyName = "Ton_Kho3";
            style13.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn12.DefaultCellStyle = style13;
            this.numericColumn12.HeaderText = "Thành phẩm";
            this.numericColumn12.Name = "numericColumn12";
            this.numericColumn12.ReadOnly = true;
            this.numericColumn12.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn12.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn12.Width = 80;
            this.numericColumn13.DataPropertyName = "Ton_Kho4";
            style14.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn13.DefaultCellStyle = style14;
            this.numericColumn13.HeaderText = "Yêu cầu nhập";
            this.numericColumn13.Name = "numericColumn13";
            this.numericColumn13.ReadOnly = true;
            this.numericColumn13.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn13.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn13.Visible = false;
            this.numericColumn13.Width = 80;
            this.numericColumn14.DataPropertyName = "Ton_Kho5";
            style15.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn14.DefaultCellStyle = style15;
            this.numericColumn14.HeaderText = "Yêu cầu xuất";
            this.numericColumn14.Name = "numericColumn14";
            this.numericColumn14.ReadOnly = true;
            this.numericColumn14.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn14.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn14.Width = 80;
            this.numericColumn15.DataPropertyName = "Ton_Kho0";
            style16.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn15.DefaultCellStyle = style16;
            this.numericColumn15.HeaderText = "Tổng";
            this.numericColumn15.Name = "numericColumn15";
            this.numericColumn15.ReadOnly = true;
            this.numericColumn15.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn15.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn15.Width = 80;
            this.numericColumn17.DataPropertyName = "So_Luong";
            style17.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.numericColumn17.DefaultCellStyle = style17;
            this.numericColumn17.HeaderText = "Lập";
            this.numericColumn17.Name = "numericColumn17";
            this.numericColumn17.SortMode = DataGridViewColumnSortMode.Automatic;
            this.numericColumn17.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
            this.numericColumn17.Width = 80;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.ClientSize = new Size(0x31a, 0x214);
            base.Controls.Add(this.btnClose);
            base.Controls.Add(this.btnMakeCommand);
            base.Controls.Add(this.btnMakeRequire);
            base.Controls.Add(this.grdContainer);
            this.MinimumSize = new Size(0x322, 0x236);
            base.Name = "FormCTSXF0Editor";
            this.Text = "C\x00e2n đối vật tư";
            this.grdContainer.Panel1.ResumeLayout(false);
            this.grdContainer.Panel2.ResumeLayout(false);
            this.grdContainer.ResumeLayout(false);
            ((ISupportInitialize) this.grdMaster).EndInit();
            ((ISupportInitialize) this.grdDetail).EndInit();
            base.ResumeLayout(false);
        }

        private void MakeCommand_Click(object sender, EventArgs e)
        {
            this.OnSelected();
            new FormCTSXEditor(3, this.LocalMasterRow, this.LocalSelectedTable).Show();
        }

        private void MakeRequire_Click(object sender, EventArgs e)
        {
            this.OnSelected();
            new FormCTYCMEditor(3, this.LocalMasterRow, this.LocalSelectedTable).Show();
        }

        private void MasterGrid_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if ((this.MasterGrid.CurrentRow != null) || (this.MasterGrid.CurrentRow.DataBoundItem != null))
            {
                DataRow row = ((DataRowView) this.MasterGrid.CurrentRow.DataBoundItem).Row;
                this.MasterKey = row["Stt0"].ToString();
            }
        }

        private void OnFillData()
        {
            this.LocalMasterTable = this.oMethod.GetMasterCommand(this.ParentKey);
        }

        private void OnSelected()
        {
            if ((this.LocalDetailTable != null) && (this.LocalDetailTable.Rows.Count != 0))
            {
                foreach (DataRow row2 in this.LocalDetailTable.Rows)
                {
                    if (row2.RowState != DataRowState.Deleted)
                    {
                        if (row2["So_Luong"].Equals(DBNull.Value))
                        {
                            row2["So_Luong"] = 0;
                        }
                        object[] keys = new object[] { row2["Stt0"], row2["Ma_Vt"] };
                        DataRow row = this.LocalSelectedTable.Rows.Find(keys);
                        if (row == null)
                        {
                            row = this.LocalSelectedTable.NewRow();
                        }
                        row["Stt0"] = row2["Stt0"];
                        row["Ma_Bp"] = row2["Ma_Bp"];
                        row["Ma_Hd"] = row2["Ma_Hd"];
                        row["Ma_Vt"] = row2["Ma_Vt"];
                        row["Ten_Vt"] = row2["Ten_Vt"];
                        row["Dvt"] = row2["Dvt"];
                        row["So_Luong"] = row2["So_Luong"];
                        if (row.RowState == DataRowState.Detached)
                        {
                            this.LocalSelectedTable.Rows.Add(row);
                        }
                    }
                }
            }
        }

        private void OnShowDetail()
        {
            this.OnSelected();
            DataRow row = ((DataRowView) this.MasterGrid.CurrentRow.DataBoundItem).Row;
            if (row["Ma_Vt_Nh"].ToString() == "V")
            {
                this.CreateDetailTable();
                object[] keys = new object[] { row["Stt0"], row["Ma_Vt"] };
                DataRow row2 = this.LocalSelectedTable.Rows.Find(keys);
                DataRow row3 = this.LocalDetailTable.NewRow();
                row3["Stt0"] = row["Stt0"];
                row3["Ma_Bp"] = row["Ma_Bp"];
                row3["Ma_Hd"] = row["Ma_Hd"];
                row3["Ma_Vt"] = row["Ma_Vt"];
                row3["Ten_Vt"] = row["Ten_Vt"];
                row3["Dvt"] = row["Dvt"];
                row3["Ton_Kho1"] = row["Ton_Kho1"];
                row3["Ton_Kho2"] = row["Ton_Kho2"];
                row3["Ton_Kho3"] = row["Ton_Kho3"];
                row3["Ton_Kho4"] = row["Ton_Kho4"];
                row3["Ton_Kho5"] = row["Ton_Kho5"];
                row3["Ton_Kho0"] = row["Ton_Kho0"];
                if (row2 != null)
                {
                    row3["So_Luong"] = row2["So_Luong"];
                }
                else
                {
                    row3["So_Luong"] = 0;
                }
                this.LocalDetailTable.Rows.Add(row3);
            }
            else
            {
                this.LocalDetailTable = this.oMethod.GetDetailCommand(this.MasterKey);
            }
            foreach (DataRow row5 in this.LocalDetailTable.Rows)
            {
                if (row5.RowState != DataRowState.Deleted)
                {
                    object[] objArray2 = new object[] { row5["Stt0"], row5["Ma_Vt"] };
                    DataRow row4 = this.LocalSelectedTable.Rows.Find(objArray2);
                    if (row4 != null)
                    {
                        row5["So_Luong"] = row4["So_Luong"];
                    }
                }
            }
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == (Keys.Control | Keys.Return))
            {
                this.OnSelected();
                this.CheckAccepted = true;
                base.Close();
            }
            else if (keyData == Keys.Escape)
            {
                base.Close();
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

        public bool CheckAccepted
        {
            get
            {
                return this.ib_CheckAccepted;
            }
            set
            {
                this.ib_CheckAccepted = value;
            }
        }

        private GridControl DetailGrid
        {
            get
            {
                return this.grdDetail;
            }
        }

        private DataTable LocalDetailTable
        {
            get
            {
                return this.oLocalDetailTable;
            }
            set
            {
                this.oLocalDetailTable = value;
                this.oLocalDetailTable.Columns.Add(new DataColumn("So_Luong", typeof(decimal)));
                this.DetailGrid.DataSource = new BindingSource(this.oLocalDetailTable, this.oLocalDetailTable.TableName);
            }
        }

        private DataRow LocalMasterRow
        {
            get
            {
                return this.oParentRow;
            }
            set
            {
                this.oParentRow = value;
            }
        }

        private DataTable LocalMasterTable
        {
            get
            {
                return this.oLocalMasterTable;
            }
            set
            {
                this.oLocalMasterTable = value;
                this.MasterGrid.DataSource = new BindingSource(this.oLocalMasterTable, this.oLocalMasterTable.TableName);
            }
        }

        private DataTable LocalSelectedTable
        {
            get
            {
                return this.oLocalSelectedTable;
            }
            set
            {
                this.oLocalSelectedTable = value;
            }
        }

        private GridControl MasterGrid
        {
            get
            {
                return this.grdMaster;
            }
        }

        private object MasterKey
        {
            get
            {
                return this.is_MasterKey;
            }
            set
            {
                if (this.is_MasterKey != value)
                {
                    this.is_MasterKey = value;
                    this.OnShowDetail();
                }
            }
        }

        private object ParentKey
        {
            get
            {
                return this.is_ParentKey;
            }
            set
            {
                this.is_ParentKey = value;
            }
        }
    }
}

